<template>
    <el-container class="mainbox">
        <el-header> <Head :userinfo="userinfo" />  </el-header>
        <el-container class="subbox">
            <el-aside width="170px" >
                <Menu :userinfo="userinfo" ref="menu" />
            </el-aside>
                <el-container>
                    <el-main>
                        <router-view></router-view>
                    </el-main>
                </el-container>
        </el-container>
         <el-footer>
             <Foot/>
         </el-footer>
    </el-container>
</template>

<script>
import Foot from "@/components/Foot.vue"
import Head from "@/components/Head.vue"

import {mapMutations} from "vuex"  
export default {
    components:{
        Foot,
        Head
    },
    data(){
        return {
            userinfo:null
        }
    },
    methods:{
        ...mapMutations(['changeuesrinfo'])  // {...{mobile:mobile}} 发送信号 要修改数据 this.changeuesrinfo ['changeuesrinfo']  {changeuesrinfo}
    },
    mounted(){
        this.$axios.post("/vue/userinfo")
        .then(res=>{
            this.userinfo = res.data.result;
            this.changeuesrinfo(this.userinfo);
            if(this.$route.name=="main"){

                this.$router.push({path:this.userinfo.rolltype=='1'?'/main/stuhome':'/main/teacherhome'});
                this.$refs.menu.active = this.userinfo.rolltype=='1'?'/main/stuhome':'/main/teacherhome';
            }
        })
    }
}
</script>

<style lang="scss" >
.el-header{
    padding:0;
}
.mainbox{
    width:100%;
    height:100%;
}

</style>


